package com.mk.admin.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.query.*;
import com.mk.admin.service.MedicalService;
import com.mk.admin.util.HttpTool;
import org.springframework.stereotype.Service;

@Service
public class MedicalServiceImpl implements MedicalService {
    @Override
    public ResultDto list(MedicalListQuery query) {
        JSONObject jsonObject = HttpTool.postJson("com_0022", query);
        Object result = jsonObject.get("result");
        if (result != null) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto inventory(MedicalInventoryQuery query) {
        JSONObject jsonObject = HttpTool.postJson("com_0023", query);
        Object result = jsonObject.get("result");
        if (result != null) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto useWay(MedicalUseWayQuery query) {
        JSONObject jsonObject = HttpTool.postJson("com_0025", query);
        Object result = jsonObject.get("result");
        if (result != null) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto decoctWay(MedicalDecoctWayQuery query) {
        JSONObject jsonObject = HttpTool.postJson("com_0026", query);
        Object result = jsonObject.get("result");
        if (result != null) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto decoctDesc(MedicalDecoctDescQuery query) {
        JSONObject jsonObject = HttpTool.postJson("com_0027", query);
        Object result = jsonObject.get("result");
        if (result != null) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto takeWay(MedicalTakeWayQuery query) {
        JSONObject jsonObject = HttpTool.postJson("com_0028", query);
        Object result = jsonObject.get("result");
        if (result != null) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

}
